home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 2010 April / PCWorld0410.iso / hity wydania / Ubuntu 9.10 PL / karmelkowy-koliberek-9.10-netbook-remix-PL.iso / casper / filesystem.squashfs / usr / share / hplip / ui4 / systrayframe.py < prev    next >
Text File  |  2009-10-09  |  7KB  |  166 lines

  1. # -*- coding: utf-8 -*-
  2. #
  3. # (c) Copyright 2001-2009 Hewlett-Packard Development Company, L.P.
  4. #
  5. # This program is free software; you can redistribute it and/or modify
  6. # it under the terms of the GNU General Public License as published by
  7. # the Free Software Foundation; either version 2 of the License, or
  8. # (at your option) any later version.
  9. #
  10. # This program is distributed in the hope that it will be useful,
  11. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13. # GNU General Public License for more details.
  14. #
  15. # You should have received a copy of the GNU General Public License
  16. # along with this program; if not, write to the Free Software
  17. # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
  18. #
  19. # Author: Don Welch
  20. #
  21.  
  22. # Local
  23. from base.g import *
  24. from base.codes import *
  25. from ui_utils import *
  26.  
  27. # Qt
  28. from PyQt4.QtCore import *
  29. from PyQt4.QtGui import *
  30.  
  31.  
  32. class SystrayFrame(QFrame):
  33.     def __init__(self, parent):
  34.         QFrame.__init__(self, parent)
  35.  
  36.  
  37.     def initUi(self, systray_visible, polling, polling_interval, device_list, systray_messages):
  38.         self.systray_visible = systray_visible
  39.         self.polling = polling
  40.         self.polling_interval = polling_interval
  41.         self.device_list = device_list
  42.         self.systray_messages = systray_messages
  43.  
  44.         self.gridlayout = QGridLayout(self)
  45.  
  46.         self.frame = QFrame(self)
  47.         self.frame.setFrameShape(QFrame.StyledPanel)
  48.         self.frame.setFrameShadow(QFrame.Raised)
  49.  
  50.         self.gridlayout1 = QGridLayout(self.frame)
  51.  
  52.         self.groupBox_2 = QGroupBox(self.frame)
  53.  
  54.         self.gridlayout2 = QGridLayout(self.groupBox_2)
  55.  
  56.         self.ShowAlwaysRadioButton = QRadioButton(self.groupBox_2)
  57.         self.gridlayout2.addWidget(self.ShowAlwaysRadioButton,0,0,1,1)
  58.  
  59.         self.HideWhenInactiveRadioButton = QRadioButton(self.groupBox_2)
  60.         self.gridlayout2.addWidget(self.HideWhenInactiveRadioButton,1,0,1,1)
  61.  
  62.         self.HideAlwaysRadioButton = QRadioButton(self.groupBox_2)
  63.         self.gridlayout2.addWidget(self.HideAlwaysRadioButton,2,0,1,1)
  64.  
  65.         self.gridlayout1.addWidget(self.groupBox_2,0,0,1,1)
  66.  
  67.         self.groupBox_3 = QGroupBox(self.frame)
  68.  
  69.         self.gridlayout3 = QGridLayout(self.groupBox_3)
  70.  
  71.         self.label_2 = QLabel(self.groupBox_3)
  72.         self.gridlayout3.addWidget(self.label_2,0,0,1,1)
  73.  
  74.         self.MessageShowComboBox = QComboBox(self.groupBox_3)
  75.         self.gridlayout3.addWidget(self.MessageShowComboBox,1,0,1,1)
  76.  
  77.         self.MessageShowComboBox.addItem(self.__tr("All"), QVariant(SYSTRAY_MESSAGES_SHOW_ALL))
  78.         self.MessageShowComboBox.addItem(self.__tr("Errors and Warnings"), QVariant(SYSTRAY_MESSAGES_SHOW_ERRORS_AND_WARNINGS))
  79.         self.MessageShowComboBox.addItem(self.__tr("Errors Only"), QVariant(SYSTRAY_MESSAGES_SHOW_ERRORS_ONLY))
  80.         self.MessageShowComboBox.addItem(self.__tr("None"), QVariant(SYSTRAY_MESSAGES_SHOW_NONE))
  81.  
  82.         spacerItem = QSpacerItem(20,40,QSizePolicy.Minimum,QSizePolicy.Minimum)
  83.         self.gridlayout3.addItem(spacerItem,2,0,1,1)
  84.         self.gridlayout1.addWidget(self.groupBox_3,0,1,1,1)
  85.  
  86.         self.MonitorGroupBox = QGroupBox(self.frame)
  87.         self.MonitorGroupBox.setCheckable(True)
  88.  
  89.         self.MonitorGroupBox.setEnabled(False)
  90.  
  91.         self.gridlayout4 = QGridLayout(self.MonitorGroupBox)
  92.  
  93.         self.label = QLabel(self.MonitorGroupBox)
  94.         self.gridlayout4.addWidget(self.label,0,0,1,1)
  95.  
  96.         self.listWidget = QListWidget(self.MonitorGroupBox)
  97.         self.gridlayout4.addWidget(self.listWidget,1,0,1,1)
  98.         self.gridlayout1.addWidget(self.MonitorGroupBox,1,0,1,2)
  99.         self.gridlayout.addWidget(self.frame,0,0,1,1)
  100.  
  101.         self.setWindowTitle(QApplication.translate("self", "self", None, QApplication.UnicodeUTF8))
  102.         self.groupBox_2.setTitle(QApplication.translate("self", "System tray icon visibility", None, QApplication.UnicodeUTF8))
  103.         self.ShowAlwaysRadioButton.setText(QApplication.translate("self", "Always show", None, QApplication.UnicodeUTF8))
  104.         self.HideWhenInactiveRadioButton.setText(QApplication.translate("self", "Hide when inactive", None, QApplication.UnicodeUTF8))
  105.         self.HideAlwaysRadioButton.setText(QApplication.translate("self", "Always hide", None, QApplication.UnicodeUTF8))
  106.         self.groupBox_3.setTitle(QApplication.translate("self", "System tray icon messages", None, QApplication.UnicodeUTF8))
  107.         self.label_2.setText(QApplication.translate("self", "Messages to show:", None, QApplication.UnicodeUTF8))
  108.         self.MonitorGroupBox.setTitle(QApplication.translate("self", "Monitor button presses on devices", None, QApplication.UnicodeUTF8))
  109.         self.label.setText(QApplication.translate("self", "Devices to monitor:", None, QApplication.UnicodeUTF8))
  110.  
  111.         self.connect(self.ShowAlwaysRadioButton, SIGNAL("clicked(bool)"), self.ShowAlwaysRadioButton_clicked)
  112.         self.connect(self.HideWhenInactiveRadioButton, SIGNAL("clicked(bool)"), self.HideWhenInactiveRadioButton_clicked)
  113.         self.connect(self.HideAlwaysRadioButton, SIGNAL("clicked(bool)"), self.HideAlwaysRadioButton_clicked)
  114.         self.connect(self.MessageShowComboBox, SIGNAL("activated(int)"), self.MessageShowComboBox_activated)
  115.  
  116.  
  117.     def updateUi(self):
  118.         self.updateVisibility()
  119.         self.updateMessages()
  120.         self.updateDeviceList()
  121.  
  122.  
  123.     def updateVisibility(self):
  124.         if self.systray_visible == SYSTRAY_VISIBLE_SHOW_ALWAYS:
  125.             self.ShowAlwaysRadioButton.setChecked(True)
  126.  
  127.         elif self.systray_visible == SYSTRAY_VISIBLE_HIDE_WHEN_INACTIVE:
  128.             self.HideWhenInactiveRadioButton.setChecked(True)
  129.  
  130.         else: # SYSTRAY_VISIBLE_HIDE_ALWAYS
  131.             self.HideAlwaysRadioButton.setChecked(True)
  132.  
  133.  
  134.     def ShowAlwaysRadioButton_clicked(self, b):
  135.         if b: self.systray_visible = SYSTRAY_VISIBLE_SHOW_ALWAYS
  136.  
  137.  
  138.     def HideWhenInactiveRadioButton_clicked(self, b):
  139.         if b: self.systray_visible = SYSTRAY_VISIBLE_HIDE_WHEN_INACTIVE
  140.  
  141.  
  142.     def HideAlwaysRadioButton_clicked(self, b):
  143.         if b: self.systray_visible = SYSTRAY_VISIBLE_HIDE_ALWAYS
  144.  
  145.  
  146.     def updateMessages(self):
  147.         i = self.MessageShowComboBox.findData(QVariant(self.systray_messages))
  148.         if i != -1:
  149.             self.MessageShowComboBox.setCurrentIndex(i)
  150.  
  151.  
  152.     def MessageShowComboBox_activated(self, i):
  153.         sender = self.sender()
  154.         mode, ok = sender.itemData(i).toInt()
  155.         if ok:
  156.             self.systray_messages = mode
  157.  
  158.  
  159.     def updateDeviceList(self):
  160.         pass
  161.  
  162.  
  163.     def __tr(self, s, c=None):
  164.         return QApplication.translate("SystrayFrame", s, c, QApplication.UnicodeUTF8)
  165.  
  166.